import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import 'default-passive-events'
import 'es6-promise/auto'
import mainCommon from './main.common'
import router from './router'
import VConsole from 'vconsole'
import App from './App.vue'

console.log(process.env.NODE_ENV)

const vConsole = new VConsole({ maxLogNumber: 1000 })

async function prepareApp() {
  if (
    process.env.NODE_ENV === 'development' ||
    process.env.NODE_ENV === 'test'
  ) {
    const { worker } = await import('./mocks/browser')
    return worker.start()
  }

  return Promise.resolve()
}

const app = createApp(App)

mainCommon.init(app)

app.use(createPinia())

app.use(router)

prepareApp().then(() => {
  app.mount('#app')
})

